<%@ page language="java"  pageEncoding="UTF-8"%>
<%@page import="java.math.BigDecimal"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%!
String showMem(long mem){
	double gb = 1024*1024*1024;
	double mb = 1024*1024;
	double kb = 1024;
	if(mem >= gb)return new BigDecimal(mem/gb).setScale(2, BigDecimal.ROUND_HALF_UP)+"GB";
	if(mem >= mb)return new BigDecimal(mem/mb).setScale(2, BigDecimal.ROUND_HALF_UP)+"MB";
	if(mem >= kb)return new BigDecimal(mem/mb).setScale(2, BigDecimal.ROUND_HALF_UP)+"KB";
	return mem+"字节";
}
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>系统信息</title>

<!-- JS与CSS引用 [START] -->
<%@include file="/WEB-INF/include/head-common.jsp" %>
<!-- JS与CSS引用 [END] -->
<style type="text/css">
.info_item{
	margin:6px 2px;
	font-size: 18px;
	font-family: 黑体;
}
.mem_item{
	padding-right: 6px;
}
#dateTime{
	color:black;
	font-size: 24px;
	font-weight: bold;
}
#timerInfo{
color:white;background-color: black;border:1px solid #6AE; height:100px;overflow: auto;
width:800px;
height:300px;
}
</style>

<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
var jsBase = "<%=basePath%>sys";
$(function(){
	// 服务器时间定时刷新
	setInterval(function(){
	$.post(jsBase+"/datetime.do?"+Math.random(), null, function(data, status){
		$("#dateTime").html(data);
	});
	},1000);
	// 定时器定时刷新
	setInterval(function(){
	$.post(jsBase+"/timerinfo.do?"+Math.random(), null, function(data, status){
		$("#timerInfo").html(data);
	});
	},1000);
});
function reloadClick(){
	if(confirm("确认要重新加载配置文件吗？")){
		location.href="<%=basePath%>sys/reloadcfg.do";
	}
}
function jvmGC(){
		location.href="<%=basePath%>sys/jvmgc.do";
}
function timerControl(status){
	if(status=='1'){
		location.href='<%=basePath %>sys/timerctrl.do?status=1'
	}else if(status=='0'){
		if(confirm("确认要停止全局自动定时器吗？")){
			location.href='<%=basePath %>sys/timerctrl.do?status=0';
		}
	}
	
}
function deleteOrgAll(){
	var orgNo=$("#orgNo").val();
	var orgName = $("#orgNo option[selected]").text();
	var dateStart = $("#dateStart").val();
	var dateEnd = $("#dateEnd").val();
	if(orgNo == "" || dateStart == "" || dateEnd == ""){
		alert("删除[机构]所有流程数据时，收单机构 或 日切日期的开始与结束不能为空");
		return;
	}
	if(confirm("重量级操作，请谨慎确认！！！\r\n\r\n确认要将[日切日期区间=("+dateStart+","+dateEnd+")]，[收单机="+orgNo+orgName+"]的所有流程数据删除吗？")){
		$("#deleteForm").attr("action","<%=basePath %>sys/deleteOrgAll.do").submit();
	}
}

function deleteWebpay(){
	var dateStart = $("#dateStart").val();
	var dateEnd = $("#dateEnd").val();
	if(dateStart == "" || dateEnd == ""){
		alert("删除[前置]数据时，日切日期的开始与结束不能为空");
		return;
	}
	if(confirm("重量级操作，请谨慎确认！！！\r\n\r\n确认要将[日切日期区间=("+dateStart+","+dateEnd+")]的前置数据删除吗？")){
		$("#deleteForm").attr("action","<%=basePath %>sys/deleteWebpay.do").submit();
	}
}
</script>


<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="css/common.css"/>
</head>
<body>
<div id="main_container">

	<!-- 网页顶部信息 [START] -->
	<%@include file="/WEB-INF/include/header.jsp" %> 
	<!-- 网页顶部信息 [END] -->
	
    
    <div class="main_content">
    	<!-- 网页顶部导航菜单 [START] -->
    	<%@include file="/WEB-INF/include/main-menu.jsp" %>
        <!-- 网页顶部导航菜单 [END] -->            
                    
    <div class="center_content">  
    
    
    
    <div class="left_content">
        
    		<!-- 网页左侧菜单 [START] -->
            <%@include file="/WEB-INF/include/sidebarmenu.jsp" %>
            <!-- 网页左侧菜单 [END] --> 
            
    </div>  
    
    <div class="right_content">
    	<div class="position">
	    	<div class="position_box">当前位置：<%@include file="/WEB-INF/include/sitemap.jsp" %></div>
	    </div>   
	    
    	<h2>系统运状态信息</h2>
    	
    	
    	<div class="info_item">当前服务器时间：<span id="dateTime">${dateTime }</span></div>
    	
    	<!-- <div class="info_item">可用总内存：x{totalMemory }已用内存：x{totalMemory-freeMemory} 剩余内存：x{freeMemory } -->
    	<div class="info_item">
    		<span class="mem_item">可用总内存：<%=showMem(Long.valueOf(request.getAttribute("totalMemory").toString())) %></span>
    		<span class="mem_item">已用内存：<%=showMem(Long.valueOf(request.getAttribute("totalMemory").toString())-Long.valueOf(request.getAttribute("freeMemory").toString())) %></span>
    		<span class="mem_item">剩余内存：<%=showMem(Long.valueOf(request.getAttribute("freeMemory").toString())) %></span>
    	</div>
    	
    	
    	<div class="info_item">活动的线程数量：${threadCount }</div>
    	<button onclick="location.href='<%=basePath %>sys/info.do?'+Math.random()">刷新信息</button>
    	<hr />
    	
    	<button onclick="jvmGC()">回收内存</button>
    	<span style="color: blue">说明：指示JAVA虚拟机尽最大努力回收所有丢弃的对象，以便回收内存，频繁点击都是白费力气！</span>    	
    	<hr />
    	
    	<button onclick="timerControl('1')">启动定时器</button>
    	<button onclick="timerControl('0')">停止定时器</button>
    	<div>
    	<label>定时器监控信息：</label>
    	<div id="timerInfo">
    	</div>
    	</div>    	
    	<hr />
    	
    	<form id="deleteForm">
    	<input type="button" value="删除机构所有流程数据" onclick="deleteOrgAll()"/>
    	<input type="button" value="删除前置数据" onclick="deleteWebpay()"/>
    	<span><label class="field_label">收单机构:</label>
    		<select name="orgNo" id="orgNo">
    		<c:forEach var="org" items="${orgs}">
    		<option value="${org.orgNo}" >${org.orgShortName}</option>
    		</c:forEach>
    		</select>
    	</span>
    	<span><label class="field_label">日切日期开始:</label><input id="dateStart" name="dateStart"  type="text" onclick="WdatePicker()" class="Wdate" readonly="readonly"/></span>
    	<span><label class="field_label">日切日期结束:</label><input id="dateEnd" name="dateEnd"  type="text" onclick="WdatePicker()" class="Wdate" readonly="readonly"/></span>	 
    	</form>    	
    	<hr /> 
    	  
    	<div>    	
    	<form action="<%=basePath%>getdata/monitor/create.do" style="display: inline-block;width:100%">    	
   		<input type="submit" value="生成监听数据"/>
   		<label class="field_label">结算日期:</label><input id="clearingDate" name="clearingDate"  type="text" onclick="WdatePicker()" class="Wdate" readonly="readonly"/>    		
   		<span style="color: blue;display: inline-block;width:100%">说明：可不选日期，如果不指定日期则默认“生成当日监听数据”，不允许指定日期超出当天的日切日期。</span>    	
    	</form>
    	</div>
    	<hr />
     </div>
     <!-- end of right content-->
            
                    
  </div>   
  <!--end of center content -->               
                    
                    
    
    
    <div class="clear"></div>
    </div> <!--end of main content-->
	
    
    <div class="footer">
    
    	<div class="left_footer">IN ADMIN PANEL | Powered by <a href="http://indeziner.com">INDEZINER</a></div>
    	<div class="right_footer"><a href="http://indeziner.com"><img src="images/indeziner_logo.gif" alt="" title="" border="0" /></a></div>
    
    </div>

</div>		
</body>
</html>
